{extend name="../../admin/view/main"}

{block name='content'}
<form action="{:sysuri()}" class="layui-card layui-form" data-auto="true" method="post">
    <div class="layui-card-body">


        <label class="layui-form-item relative block">
            <span class="help-label"><b>园区名称</b></span>
            <input class="layui-input" name="park_name" placeholder="请输入园区名称" required value='{$vo.park_name|default=""}'>
        </label>

        <div class="layui-form-item label-required-prev">
            <span class="help-label"><b>园区区域</b></span>
            <select class="layui-select" lay-filter="regional_id" required name="regional_id" lay-search>
                <option value="">-- 请选择 --</option>
                {if !empty($vo.regional_id)}
                {foreach $park_regionals_list as $k=>$v}
                <!-- {if $v.id eq $vo.regional_id} -->
                <option selected value="{$v.id}">{$v.regional_name|default="无"}</option>
                <!-- {else} -->
                <option value="{$v.id}">{$v.regional_name|default="无"}</option>
                <!-- {/if} -->
                {/foreach}
                {else}
                {foreach $park_regionals_list as $k=>$v}
                <option value="{$v.id}">{$v.regional_name|default="无"} </option>
                {/foreach}
                {/if}
            </select>
        </div>


        <div class="layui-col-xs12 label-required-prev" style="margin-bottom:10px;">
            <span class="help-label"><b>园区产业</b></span>
            <span class="color-desc margin-left-5"></span>
            <div id="peipeiList1" class="xm-select-demo" ></div>
            <input type="hidden" name="industry_id" id="industry_id" value="{$vo.industry_id|default=''}">
        </div>


        <label class="layui-form-item relative block">
            <span class="help-label"><b>园区类型</b></span>
            <input class="layui-input" name="park_type" placeholder="请输入园区类型" required value='{$vo.park_type|default=""}'>
        </label>

        <label class="layui-form-item relative block">
            <span class="help-label"><b>地址</b></span>
            <input class="layui-input" name="address" placeholder="请输入地址" required value='{$vo.address|default=""}'>
        </label>

        <div class="layui-form-item label-required-prev">
            <span class="help-label"><b>优势</b></span>
            <div class="relative block">
                <textarea class="layui-hide" name="advantages" placeholder="请输入优势">{$vo.advantages|default=''}</textarea>
            </div>
        </div>


        <label class="layui-form-item relative block">
            <span class="help-label"><b>联系人</b></span>
            <input class="layui-input" name="park_contact" placeholder="请输入联系人" required value='{$vo.park_contact|default=""}'>
        </label>

        <label class="layui-form-item relative block">
            <span class="help-label"><b>联系人电话</b></span>
            <input class="layui-input" name="contact_phone" placeholder="请输入联系人电话" required value='{$vo.contact_phone|default=""}'>
        </label>


        <div class="layui-form-item label-required-prev">
            <span class="help-label"><b>封面图</b></span>
            <div class="relative block label-required-null">
                <input class="layui-input think-bg-gray" name="cover_img" placeholder="请上传封面" readonly required value='{$vo.cover_img|default=""}'>
                <a class="layui-icon layui-icon-upload input-right-icon" data-file data-field="cover_img" data-type="gif,png,jpg,jpeg"></a>
            </div>
        </div>

        <div class="layui-form-item relative">
            <span class="help-label" style="padding-right: 10px;"><b>是否热门</b></span>

            {if !empty($vo.is_hot)}
            <input type="radio" name="is_hot" lay-filter="is_hot" value="0"  title="非热门"  {if $vo.is_hot!=1}checked{/if}>
            <input type="radio" name="is_hot" lay-filter="is_hot" value="1"  title="热门" {if $vo.is_hot==1}checked{/if}>
            {else}
            <input type="radio" name="is_hot" lay-filter="is_hot" value="0"  title="非热门" checked>
            <input type="radio" name="is_hot" lay-filter="is_hot" value="1"  title="热门" >
            {/if}

        </div>

        <div class="hr-line-dashed"></div>
        {notempty name='vo.id'}<input name='id' type='hidden' value='{$vo.id}'>{/notempty}

        <div class="layui-form-item text-center">
            <button class="layui-btn" type="submit">保存数据</button>
            <button class="layui-btn layui-btn-danger" data-history-back data-confirm="确定要取消编辑吗？" type='button'>取消编辑</button>
        </div>
    </div>

</form>

<script>
    $('input[name="cover_img"]').uploadOneImage();
    require(['ckeditor'], function () {
        window.createEditor('[name=advantages]', {height: 350})
    });
</script>
<script>

    $(function () {
        getIndustryIdList();
    });
    function getIndustryIdList() {
        layui.use('xmSelect', function () {
            $.ajax({
                type: 'get',
                url: "{:url('getIndustryIdList')}",
                data: "",
                dataType: "json",
                success: function (res) {
                    if (res.code) {
                        console.log(res);
                        var datas = [];
                        res.data.forEach(function (item) {
                            var uuid = "{$vo.industry_id|default=''}".split(',');
                            if (uuid.length && uuid.findIndex(it => it == item.id) != -1) {
                                datas.push({name: item.industry_name, value: item.id, selected: true});

                            } else {
                                datas.push({name: item.industry_name, value: item.id});
                            }
                        });
                        xmSelect.render({
                            el: '#peipeiList1',
                            tips: '请选择园区产业',//选项提示文字
                            data: datas,
                            on: function (data) {
                                var selectArr = data.arr;
                                var seachArr = [];
                                for (var j = 0; j < selectArr.length; j++) {
                                    seachArr.push(selectArr[j].value)
                                }
                                $("#industry_id").val(seachArr.toString());
                            }
                        })
                    } else {
                        console.log(res.info);
                    }
                },
                error: function (err) {
                    console.log(err)
                }
            });
        });
    }
</script>

{/block}
